package com.zj.study.handle;

import com.zj.study.pojo.FinalResultVO;
import com.zj.study.utils.execption.ValidationException;
import org.springframework.http.ResponseEntity;

/**
 * @author 赵赳
 * @since 2021/9/23 13:47
 */
public class ValidationExceptionHandler implements ExceptionHandler {

  @Override
  public boolean match(Class<?> clazz) {
    return ValidationException.class == clazz;
  }

  @Override
  public ResponseEntity<?> handler(Throwable throwable) {
    return response(FinalResultVO.fail(CLIENT_BAD_PARAMETERS, throwable.getMessage()));
  }

}
